package com.colorfruit.admin.control.controller;

import com.colorfruit.admin.business.service.DistributorService;
import com.colorfruit.framework.model.pojo.BaseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequestMapping("/distributor")
@RestController
public class DistributorController {

    @Autowired
    DistributorService distributorService;

    /**
     * 获取当前地址下配送单列表
     * @param pickGoodsAddressId 拣货点地址ID
     * @param keyWord   查询条件(电话号码, 手机)
     * @param distributeStatus 配送状态 1. 未配送 2.配送中 3.配送完成 空.三个都查
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/selectBusinessOrderList")
    public BaseResult selectBusinessOrderList(Long pickGoodsAddressId, String keyWord, Byte distributeStatus, int page, int size){
        log.info("# [IN] [controller] selectBusinessOrderList param: pickGoodsAddressId = {}, keyWord = {}, distributeStatus = {}, page = {}, size = {}",
                pickGoodsAddressId, keyWord, distributeStatus, page, size);
        BaseResult baseResult = distributorService.selectBusinessOrderList(pickGoodsAddressId, keyWord, distributeStatus, page, size);
        log.info("# [OUT] [controller] selectBusinessOrderList SUCCESS");
        return baseResult;
    }

    /**
     * 添加物流照片
     * @param businessNo 业务订单号
     * @param logicPicture 物流照片
     * @return
     */
    @RequestMapping("/addLogicPicture")
    public BaseResult addLogicPicture(String businessNo, String logicPicture){
        log.info("# [IN] [controller] addLogicPicture param: businessNo = {}, logicPicture = {}", businessNo, logicPicture);
        BaseResult baseResult = distributorService.addLogicPicture(businessNo, logicPicture);
        log.info("# [OUT] [controller] addLogicPicture SUCCESS");
        return baseResult;
    }

    /**
     * 更新订单状态未配送中
     * @param businessNo 业务订单号
     * @return
     */
    @RequestMapping("/updateDistributing")
    public BaseResult updateDistributing(String businessNo){
        log.info("# [IN] [controller] updateDistributing param: businessNo = {}", businessNo);
        BaseResult baseResult = distributorService.updateDistributing(businessNo);
        log.info("# [OUT] [controller] updateDistributing SUCCESS");
        return baseResult;
    }
}
